/**
 * @(#)PDSysSettingCommon.java 1.0 2013/9/4
 * Copyright 2013 PD, Inc. All rights reserved.
 */
package cn.broadin.app.hotel.stb.impl.common;
import java.util.HashMap;

import cn.broadin.app.hotel.stb.IPDSysSetting;
import android.app.Activity;
import android.util.Log;
import android.webkit.JavascriptInterface;


/**
 * PDSysSettingCommon 系统环境变量读写通用
 * @author fenghui
 *
 */
public class PDSysSettingCommon implements IPDSysSetting{

	//日志tag
	private static final String TAG = "PDSysSettingCommon";
	private Activity activty = null;
	
	//环境变量保存夫容器
	private HashMap<String, String> syssettings = new HashMap<String, String>(); 
	
	public PDSysSettingCommon(Activity act) {
		this.activty = act;
	}

	@Override
	@JavascriptInterface
	public void setEnv(String key, String value) {
		Log.i(TAG, "setEnv info, key is '" + key + "', value is '" + value + "'");
		syssettings.put(key, value);
	}

	@Override
	@JavascriptInterface
	public String getEnv(String key) {
		Log.i(TAG, "getEnv info, key is '" + key + "', value is '" + syssettings.get(key) + "'");
		return syssettings.get(key);
	}

	@Override
	@JavascriptInterface
	public void deleteEnv(String key) {
		if(syssettings.containsKey(key)) {
			Log.i(TAG, "deleteEnv info, key is '" + key + "'");
			syssettings.remove(key);
		}
	}

	@Override
	@JavascriptInterface
	public void exit() {
		Log.i(TAG, "exit");
		Log.d("caolm:",this.activty.getLocalClassName());
		this.activty.finish();
		//System.exit(0);
	}

	@Override
	@JavascriptInterface
	public void menu() {
		Log.i(TAG, "menu");
		this.activty.finish();
		//System.exit(0);
	}

	@Override
	@JavascriptInterface
	public void standby() {
		Log.i(TAG, "standby");
	}
}